<?php

include_once(OBJECT_PATH . "/Component.php");
include_once(DAO_PATH . "/ComponentDAO.php");
include_once("UCController.php");

class UCEditComponent implements UCController
{
	function run()
	{
		// objects to be utilised during this use case
		$component = new Component();
		$dao = new ComponentDAO();

		// get the variables from the php POST method
                $component->setId($_REQUEST['component']);
		$component->setCategory($_REQUEST['category']);
		$component->setName($_REQUEST['name']);
		$component->setDescription($_REQUEST['description']);
		$component->setStock($_REQUEST['stock']);
		$component->setPrice($_REQUEST['price']);


		// send the new component to the dao process for processing
		$result= $dao->editComponent($component);
		if ($result == true)
		{
			echo "Component has been successfully edited";
		}
		else
		{
			echo "Error detected, the operation was unsuccessful";
		}
	}
}

?>